<!DOCTYPE html>
<html lang="zh-cn"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head th:replace="common::head"></head>
<body>
<div th:replace="common::top"></div>
<br/>
<h2>订单详情</h2>
<div id="print">
<table>
    <tr>
        <td colspan="6" th:text="${corporate}"></td>
    </tr>
    <tr>
        <td colspan="6">销售清单</td>
    </tr>
    <tr>
        <td>客户名称</td>
        <td colspan="2" th:text="${order.customName}"></td>
        <td>日期</td>
        <td colspan="2" th:text="${#dates.format(order.createTime,'yyyy-MM-dd HH:mm')}"></td>
    </tr>
    <tr>
        <td>序号</td>
        <td>产品名称</td>
        <td>数量</td>
        <td>单价</td>
        <td>合计</td>
        <td>备注</td>
    </tr>
    <tbody>
    <tr th:each="item : ${batchList}">
        <td th:text="${itemStat.index+1}"></td>
        <td th:text="${item.productName}"></td>
        <td th:text="${item.orderNum}"></td>
        <td th:text="${item.price} / 100"></td>
        <td th:text="${item.amount} / 100"></td>
        <td th:text="${item.remark}"></td>
    </tr>
    </tbody>
</table>
</div>
<input type="button" onclick="printTable()" value="打印">
<p>
    <a href="javascript:history.back(-1);">上一页</a>
    <a href="../index.html" th:href="@{/index.html}">主页</a>
</p>

</body>
<script>
    function printTable() {
        var body = document.body.innerHTML;
        document.body.innerHTML = document.getElementById("print").innerHTML;
        if(!!window.ActiveXObject || "ActiveXObject" in window) {
					remove_ie_header_and_footer();
		}
        window.print();
        window.close();
        document.body.innerHTML = body;
    }

    function remove_ie_header_and_footer() {
        var hkey_path;
        hkey_path = "HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
        try {
            var RegWsh = new ActiveXObject("WScript.Shell");
            RegWsh.RegWrite(hkey_path + "header", "");
            RegWsh.RegWrite(hkey_path + "footer", "");
        } catch(e) {

        }
    }

</script>
</html>